import axios from 'axios'
import store from '@/store'
const { userTokens } = store.state
const http = axios.create({
  baseURL: 'http://ttapi.research.itcast.cn/app/'
})

// 设置全局请求头
http.interceptors.request.use((config) => {
  if (userTokens && userTokens.token) {
    config.headers.Authorization = 'Bearer ' + userTokens.token
  }
  return config
})

export default http
